package com.app.newiptv.adaper;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.app.newiptv.R;
import com.app.newiptv.presenter.TestRecyclePresenter;

/**
 * Created by wendal on 2017/9/11.
 */

public class TestRecycleAdaper extends RecyclerView.Adapter<TestRecycleAdaper.TestRecycleViewHolder> {
    private TestRecyclePresenter presenter;
    private int count;
    public TestRecycleAdaper(TestRecyclePresenter presenter){
        this.presenter = presenter;
    }
    public void setCount(int count){
        this.count = count;
    }
    @Override
    public TestRecycleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.test_item, null);
        TestRecycleViewHolder viewHolder = new TestRecycleViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(TestRecycleViewHolder holder, int position) {
        presenter.onBindMovieView(holder,position);
    }

    @Override
    public int getItemCount() {
        return count;
    }

    public class TestRecycleViewHolder extends RecyclerView.ViewHolder implements TestRecyclePresenter.ViewHolder{
        private TextView textView;
        public TestRecycleViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.test_item);
            itemView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View view, boolean b) {
                    if(b){

                    }else{

                    }
                }
            });
        }

        @Override
        public void setName(String name) {
            textView.setText(name);
        }
    }
}
